package me.zhengjie.modules.customer.repository;

import me.zhengjie.modules.customer.domain.TCustomerInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
* @author xuyukun
* @date 2019-07-21
*/
public interface TCustomerInfoRepository extends JpaRepository<TCustomerInfo, Long>, JpaSpecificationExecutor {

    //@Query(value="select * from TCustomerInfo t where t.customerCode like %:param% or t.customerName like %:param%", nativeQuery = true)
    //List<TCustomerInfo> queryByCodeOrName(@Param("param") String param);

    @Query(value="select t from TCustomerInfo t where t.customerCode like %?1% or t.customerName like %?2%")
    List<TCustomerInfo> findByCustomerCodeLikeOrCustomerNameLike(String customerCode,String customerName);

    TCustomerInfo findByCustomerName(String customerName);
}